<?php
/**
 * Factory.php - 27 Jan 2009
 * 
 * The factory class determines which bootstrap class to create according to 
 * environmental specific parameters. The conditions that are used to determine
 * it are all based on assumptions. This class basically asks itself the 
 * following questions:
 * 
 * - Running on a server with the name that is specified in 
 *   KB_Environment::localhostServerName (default is 'localhost')?
 * > Than create a dev environment. 
 *
 * - (yet to determine when creating the test environment)
 *
 * - Does none of the above questions apply in the current situation?
 * > Than create a production environment
 *
 * @author Kevin Breed
 */

require_once( 'KB/Bootstrap/Dev.php' );
require_once( 'KB/Bootstrap/Test.php' );
require_once( 'KB/Bootstrap/Production.php' );
require_once( 'KB/DynamicObject.php' );

class KB_Bootstrap_Factory
{	
	/**
	 * @var mixed	Instance of KB_Bootstrap_Live or KB_Dynamic_Object
	 */
	public $dev = null;
	
	/**
	 * @var mixed	Instance of KB_Bootstrap_Local or KB_Dynamic_Object
	 */
	public $test = null;
	
	/**
	 * @var mixed	Instance of KB_Bootstrap_Local or KB_Dynamic_Object
	 */
	public $production = null;
	
	
	/**
	 * @var KB_Bootstrap_Environment Instance of KB_Environment
	 */
	protected $_env = null;
	
	
	/**
	 * Constructor
	 */
	public function __construct ()
	{
		$this->_env = new KB_Environment();
		
		$this->dev 			= new KB_DynamicObject();
		$this->test 		= new KB_DynamicObject();
		$this->production	= new KB_DynamicObject();
	}
	
	/** 
	 * Create bootstrap instance
	 */
	public function createBootstrap ()
	{
		if ( $this->_env->isLocal() ) 	return $this->_createDevBootstrap();
		else 							return $this->_createProductionBootstrap();
	}
	
	/**
	 * Create a dev bootstrap instance
	 */
	protected function _createDevBootstrap ()
	{
		$this->dev = new KB_Bootstrap_Dev();
		return $this->dev;
	}
	
	/**
	 * Create a test bootstrap instance
	 */
	protected function _createTestBootstrap ()
	{
		$this->test = new KB_Bootstrap_Test();
		return $this->test;
	}
	
	/**
	 * Create a production bootstrap instance
	 */
	protected function _createProductionBootstrap ()
	{
		$this->production = new KB_Bootstrap_Production();
		return $this->production;
	}
}

?>
